<?php

/**
 * Project form base class.
 *
 * @package    form
 * @subpackage project
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseProjectForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'name'              => new sfWidgetFormInput(),
      'code'              => new sfWidgetFormInput(),
      'fund_id'           => new sfWidgetFormDoctrineSelect(array('model' => 'Fund', 'add_empty' => false)),
      'contract_type'     => new sfWidgetFormChoice(array('choices' => array('By Admin' => 'By Admin', 'Straight' => 'Straight'))),
      'status'            => new sfWidgetFormChoice(array('choices' => array('Pending' => 'Pending', 'Documentation Complete' => 'Documentation Complete', 'In Progress' => 'In Progress', 'Suspended' => 'Suspended', 'Completed' => 'Completed'))),
      'project_cost'      => new sfWidgetFormInput(),
      'total_bid_amount'  => new sfWidgetFormInput(),
      'computed_overhead' => new sfWidgetFormInput(),
      'days_to_complete'  => new sfWidgetFormInput(),
      'start_date'        => new sfWidgetFormDate(),
      'end_date'          => new sfWidgetFormDate(),
      'publication'       => new sfWidgetFormDate(),
      'pow'               => new sfWidgetFormDate(),
      'bidding'           => new sfWidgetFormDate(),
      'abstract'          => new sfWidgetFormDate(),
      'notice_of_award'   => new sfWidgetFormDate(),
      'contracts'         => new sfWidgetFormDate(),
      'notice_to_proceed' => new sfWidgetFormDate(),
      'dv_no'             => new sfWidgetFormInput(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorDoctrineChoice(array('model' => 'Project', 'column' => 'id', 'required' => false)),
      'name'              => new sfValidatorString(array('max_length' => 50)),
      'code'              => new sfValidatorString(array('max_length' => 10)),
      'fund_id'           => new sfValidatorDoctrineChoice(array('model' => 'Fund')),
      'contract_type'     => new sfValidatorChoice(array('choices' => array('By Admin' => 'By Admin', 'Straight' => 'Straight'), 'required' => false)),
      'status'            => new sfValidatorChoice(array('choices' => array('Pending' => 'Pending', 'Documentation Complete' => 'Documentation Complete', 'In Progress' => 'In Progress', 'Suspended' => 'Suspended', 'Completed' => 'Completed'), 'required' => false)),
      'project_cost'      => new sfValidatorNumber(array('required' => false)),
      'total_bid_amount'  => new sfValidatorNumber(array('required' => false)),
      'computed_overhead' => new sfValidatorNumber(array('required' => false)),
      'days_to_complete'  => new sfValidatorInteger(array('required' => false)),
      'start_date'        => new sfValidatorDate(array('required' => false)),
      'end_date'          => new sfValidatorDate(array('required' => false)),
      'publication'       => new sfValidatorDate(array('required' => false)),
      'pow'               => new sfValidatorDate(array('required' => false)),
      'bidding'           => new sfValidatorDate(array('required' => false)),
      'abstract'          => new sfValidatorDate(array('required' => false)),
      'notice_of_award'   => new sfValidatorDate(array('required' => false)),
      'contracts'         => new sfValidatorDate(array('required' => false)),
      'notice_to_proceed' => new sfValidatorDate(array('required' => false)),
      'dv_no'             => new sfValidatorString(array('max_length' => 50, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Project', 'column' => array('name'))),
        new sfValidatorDoctrineUnique(array('model' => 'Project', 'column' => array('code'))),
      ))
    );

    $this->widgetSchema->setNameFormat('project[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Project';
  }

}